package cn.stylefeng.guns.modular.business.controller;

import cn.stylefeng.guns.modular.business.pojo.WxExpenseRequest;
import cn.stylefeng.guns.modular.business.service.WxExpenseService;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 消费记录控制器
 *
 * @author 施律名
 * @date 2022-03-16 16:44:29
 */
@RestController
@ApiResource(name = "消费记录")
public class WxExpenseController {

    @Resource
    private WxExpenseService wxExpenseService;

    /**
     * 添加记录
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @PostResource(name = "添加记录", path = "/wx/expense/add")
    public ResponseData add(@RequestBody @Validated(WxExpenseRequest.add.class) WxExpenseRequest wxExpenseRequest) {
        wxExpenseService.add(wxExpenseRequest);
        return new SuccessResponseData();
    }

    /**
     * 删除微信消费记录
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @PostResource(name = "删除微信消费记录", path = "/wx/expense/delete")
    public ResponseData delete(@RequestBody @Validated(WxExpenseRequest.delete.class) WxExpenseRequest wxExpenseRequest) {
        wxExpenseService.del(wxExpenseRequest);
        return new SuccessResponseData();
    }

    /**
     * 编辑微信消费记录
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @PostResource(name = "编辑微信消费记录", path = "/wx/expense/edit")
    public ResponseData edit(@RequestBody @Validated(WxExpenseRequest.edit.class) WxExpenseRequest wxExpenseRequest) {
        wxExpenseService.edit(wxExpenseRequest);
        return new SuccessResponseData();
    }

    /**
     * 查看微信消费记录详情
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @GetResource(name = "查看微信消费记录详情", path = "/wx/expense/detail")
    public ResponseData detail(@Validated(WxExpenseRequest.detail.class) WxExpenseRequest wxExpenseRequest) {
        return new SuccessResponseData(wxExpenseService.detail(wxExpenseRequest));
    }

    /**
     * 查询微信消费记录列表
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @GetResource(name = "获取微信消费记录列表", path = "/wx/expense/findList")
    public ResponseData list(WxExpenseRequest wxExpenseRequest) {
        return new SuccessResponseData(wxExpenseService.findList(wxExpenseRequest));
    }

    /**
     * 分页查询微信消费记录列表
     *
     * @author 施律名
     * @date 2022-03-16 16:44:29
     */
    @GetResource(name = "分页查询", path = "/wx/expense/findPage")
    public ResponseData page(WxExpenseRequest wxExpenseRequest) {
        return new SuccessResponseData(wxExpenseService.findPage(wxExpenseRequest));
    }

}